clear all;
load('random.mat','correction_ratio');

small=prctile(correction_ratio,2.5);
middle=prctile(correction_ratio,50);
big=prctile(correction_ratio,97.5);



fig=figure('color', [1 1 1 ], 'Position',[200 20 800 720]);
handle=subplot(2,1,1);
[f, correction_ratio_hist]=hist(correction_ratio, 74);
bar(correction_ratio_hist,f/sum(f),1,'facecolor','blue');

ylim([0, 0.06]);
xlim([0.34 0.50]);
hold on
%
plot([small,small],[0, 0.06],'-.r','linewidth',1)
hold on
plot([middle,middle],[0, 0.06],'--k','linewidth',1)
hold on
plot([big,big],[0, 0.06],'-.r','linewidth',1)

annotation('arrow',[0.32  0.35],[0.895 0.895], 'LineStyle','-.','color',[1 0 0], 'Headstyle', 'vback2', 'HeadWidth', 3);
text(0.351, 0.0545, '2.5\% bound, 0.385','color',[1 0 0], 'FontSize',10,'Interpreter','Latex');

annotation('arrow',[0.498  0.528],[0.895 0.895], 'LineStyle','-.','color',[0 0 0], 'Headstyle', 'vback2', 'HeadWidth', 3);
text(0.395, 0.0545, 'median, 0.422','color',[0 0 0], 'FontSize',10,'Interpreter','Latex');

annotation('arrow',[0.728  0.698],[0.895 0.895], 'LineStyle','-.','color',[1 0 0], 'Headstyle', 'vback2', 'HeadWidth', 3);
text(0.464, 0.0545, '97.5\% bound, 0.457','color',[1 0 0], 'FontSize',10,'Interpreter','Latex');

title( 'A. Distribution of correct prediction ratios based on random selection', 'FontSize',15,'Interpreter','Latex');
xlabel('correct prediction ratio', 'FontSize',12,'Interpreter','Latex');
ylabel('probability density', 'FontSize',12,'Interpreter','Latex');

% yticks(1.0:0.3:2.5);
set(gca,'FontSize',12);

% get(handle,'position')







% clear all;
load('result_random_assignment.mat','year_diff');

handle=subplot(2,1,2);

[f, year_diff_hist]=hist(year_diff, 76);
bar(year_diff_hist,f/sum(f),1,'facecolor','blue');

annotation('arrow',[0.331  0.361],[0.421 0.421], 'LineStyle','-.','color',[1 0 0], 'Headstyle', 'vback2', 'HeadWidth', 3);
text(4.885, 0.0545, '2.5\% bound, 5.15','color',[1 0 0], 'FontSize',10,'Interpreter','Latex');

annotation('arrow',[0.487  0.517],[0.421 0.421], 'LineStyle','-.','color',[0 0 0], 'Headstyle', 'vback2', 'HeadWidth', 3);
text(5.205, 0.0545, 'median, 5.41','color',[0 0 0], 'FontSize',10,'Interpreter','Latex');

annotation('arrow',[0.702  0.672],[0.421 0.421], 'LineStyle','-.','color',[1 0 0], 'Headstyle', 'vback2', 'HeadWidth', 3);
text(5.725, 0.0545, '97.5\% bound, 5.67','color',[1 0 0], 'FontSize',10,'Interpreter','Latex');
hold on
plot([5.15,5.15],[0, 100],'-.r','linewidth',1)
hold on
plot([5.67,5.67],[0, 100],'-.r','linewidth',1)
hold on
plot([5.41,5.41],[0, 100],'--k','linewidth',1)


title( 'B. Distribution of timing differences based on random selection', 'FontSize',15,'Interpreter','Latex');
xlabel('timing difference', 'FontSize',12,'Interpreter','Latex');
ylabel('probability density', 'FontSize',12,'Interpreter','Latex');
ylim([0,0.06])
set(gca,'FontSize',12);
